<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/commons/taglibs.jsp"%><!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <%@ include file="/commons/meta.jsp"%>
    <link href="${ctx}/resources/admin/css/base.css" rel="stylesheet">
    <link href="${ctx}/resources/admin/css/zTreeStyle.css" rel="stylesheet">
</head>
<body>
<div id="loading" class="loading" >加载中…</div>
<div id="shade-div" class="shade-div hide"></div>
<div id="main" style="margin-left: 0px;">
	<form action="${ctx}/userconfig/virtual_group!save.xhtml" method="post">
	    <div id="content" class="orgStr" >
	        <div class="hd">
	            <span>权限分配>${syspower.name}>添加成员</span>
	        </div>
	        <div class="newVirtual">
	            <p><a href="javascript:;" class="btn blue-btn" id="addUserButton">添加成员</a>
	            </p>
	            
	            <P>
	            <form id="form1" action="" method="post">
                	<input id="fteamid" type="hidden" value="${syspower.id}">
                    <input type="text" class="itext gray" id="searchBy" name="username" value="输入编号、姓名、部门等进行查询" v="">
            		<button class="btn blue-btn" type="button" id="searchButton">查询</button>
                </form>
	            </P>
	        </div>
	        
	        <input type="hidden" name="users" id="users">
            <table class="table-list" id="table1">
		        <thead>
			        <tr>
			            <th><input type="checkbox" id="inputItem1"></th>
			            <th>编号</th>
			            <th>姓名</th>
			            <th>部门</th>
			            <th>操作</th>
			        </tr>
		        </thead>
		        <tbody>
			        <s:iterator value="pager.result" status="i" var="ss">
				        <tr>
				            <td><input type="checkbox" value="${ss.userid}" name="checkbox1" class="inputItem1"></td>
				            <td><s:if test="userInfo!=null&&userInfo.userCode!=null">${ss.userInfo.userCode}</s:if></td>
				            <td><s:if test="userInfo!=null&&userInfo.name!=null">${ss.userInfo.name}</s:if></td>
				            <td>${ss.dept.deptname}</td>
				            <td><a href="javascript:addUser('${ss.userid}');">添加</a></td>
				        </tr>
				    </s:iterator>
		        </tbody>
		    </table>
		    <jsp:include page="/jsps/admin/inc/pager.jsp">
				<jsp:param name="pageUrl" value="${ctx}/privilege/user_privilege!select.xhtml?syspower.id=${syspower.id}" />
			</jsp:include>
	    </div>
    </form>
</div>
<!--警告-->
<div class="popbox w300" id="warning" >
    <div class="popbox-hd">
        <h2>警告</h2>
        <a href="javascript:;" title="关闭" class="closePopBtn"></a>
    </div>
    <div class="popbox-bd">
        <p class="center"></p>
    </div>
    <div class="popbox-ft">
        <a href="javascript:;" class="btn blue-btn">确定</a><a href="javascript:;" class="btn gray-btn cancelBtn">取消</a>
    </div>
</div>

<script src="${ctx}/resources/admin/js/lib/jquery-1.8.0.min.js"></script>
<script src="${ctx}/resources/admin/js/lib/jquery.ztree.core-3.1.min.js"></script>
<script src="${ctx}/resources/admin/js/lib/jquery.ztree.excheck-3.1.min.js"></script>
<script src="${ctx}/resources/admin/js/lib/jquery.ztree.exedit-3.1.min.js"></script>
<script src="${ctx}/resources/admin/js/common.js"></script>
<script src="${ctx}/resources/admin/js/lib/jquery-ui.js"></script>
<script src="${ctx}/resources/admin/js/userConfigurationData/selectVirtualGroup.js"></script>
<script src="${ctx}/resources/admin/js/lib/ztree.js"></script>
<script type="text/javascript">
$.checkAll("inputItem1");
var num=0;
if("${pager.keyword}"!=""){
	$("#searchBy").val("${pager.keyword}");
	$("#searchBy").removeClass("gray");
	$("#searchBy").addClass("borderRed");
}
$(function(){
	common.menuClicked('P3', 'C7');
});
$("#addUserButton").click(function(){
	var x=document.getElementsByName("checkbox1");
	var u=new Array();;
	var j=0;
	for(var i=0;i<x.length;i++){
		if ( x[i].checked ){
			u[j]=x[i];
			j++;
		}
	}
	if(j==0){
		alert("请选择用户");
		return ;
	}
	var users="";
	for (var i=0;i<u.length;i++)
	{
		if(i==0){
			users+=u[i].value;
		}else{
			users+=","+u[i].value;
		}
	}
	newVirtualGroup.ajaxPOST(ctx+"/privilege/user_privilege!addUser.xhtml?syspower.id=${syspower.id}","data="+users,function(data){
		num++;
		alert("添加成功");
		common.refreshPage();
	});
});
function addUser(users){
	newVirtualGroup.ajaxPOST(ctx+"/privilege/user_privilege!addUser.xhtml?syspower.id=${syspower.id}","data="+users,function(data){
		num++;
		alert("添加成功");
		common.refreshPage();
	});
}
$("#re").click(function(){
	window.returnValue=num;
	window.close();
});
$("#searchBy").textClean();
</script>
</body>
</html>